#include <bits/stdc++.h>

using namespace std;

#define N 100005

stack<char> s;

int main(){
    while (true){
        char ch = cin.get();
        if (ch == ' ' || ch == '\n' || ch == EOF){
            while (!s.empty()){
                cout << s.top();
                s.pop();
            }

            if (ch == '\n' || ch == EOF){
                break;
            }
            
            cout << " ";
            }
        else{
                s.push(ch);
        }
    }
    return 0;
}

